package com.walnut.lom_system.common.enums;

import lombok.Data;
import org.apache.kafka.common.protocol.types.Field;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * @author chenhetao
 * @version 1.0
 * @className OrderEnum
 * @description TODO
 * @date 2022/4/26 22",34
 */
public enum OrderEnum {
    /**
     * 排序字段,招新及换届部分
     */
    TYPE("type", 1),
    NAME("name", 2),
    GENDER("gender", 3),
    CLASS_NO("classNo", 4),
    PHONE("phone", 5),
    EMAIL("email", 6),
    SCHOLARSHIP("scholarship", 7),
    C_I_1("campaignIntent1", 8),
    C_I_2("campaignIntent2", 9),
    ADJUST("adjust", 10),
    SID("sid",11),


    /**
     * 排序字段,用户部分
     */
    //TODO 添加更多的排序字段


    ;
    private String orderName;
    private int orderId;

    OrderEnum(String orderName, int orderId) {
        this.orderName = orderName;
        this.orderId = orderId;
    }

    OrderEnum(int orderId) {
        this.orderId = orderId;
    }

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    @Override
    public String toString() {
        return "OrderEnum{" +
                "orderName='" + orderName + '\'' +
                ", orderId=" + orderId +
                '}';
    }

    private static final Map<Integer, OrderEnum> MAP = new HashMap<>();

    static {

        for (OrderEnum order : values()) {
            MAP.put(order.orderId, order);
        }
    }

    /**
     * 通过Id获取对应的查询列名
     * @param orderId id
     * @return 需要查询的列名
     */
    public static OrderEnum valueOfName(Integer orderId) {
        return MAP.get(orderId);
    }

    public String toLocale() {

        if (Locale.CHINA.equals(Locale.getDefault())) {
            return orderName;
        }
        return toString();
    }

}
